<template>
  <div class="app-container">
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
      </el-col>
    </el-row>

    <el-table v-loading="loading" :data="list">
      <el-table-column label="标绘主题" align="center" prop="plottingTitle" />
      <el-table-column label="创建时间" align="center" prop="createTime" />
      <el-table-column label="发起人" align="center" prop="userName" />
      <el-table-column label="操作" align="center" fixed="right" width="150" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" @click="handleUpdate(scope.row)">修改</el-button>
          <el-button size="mini" type="text" @click="intoSynMark(scope.row)">标绘</el-button>
          <el-button size="mini" type="text" @click="handleDelete(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

    <edit-mark ref="editMark" @handleOk="onSynMarkSave" />
  </div>
</template>

<script>
import EditMark from "./components/EditMark.vue";
import * as OAApi from '@/api/oa/oa';

export default {
  name: "MeetingList",
  components: { EditMark },
  data() {
    return {
      // 遮罩层
      loading: false,
      // 显示搜索条件
      showSearch: false,
      // 总条数
      total: 0,
      // 运输机场附件表格数据
      list: [
        {
          title: "关于MU6655航班航行事故的协同标绘",
          time: "2022年8月13日 12:22:32",
          userNick: "管理员",
        },
      ],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
    };
  },
  created() {
    this.getList();
  },
  methods: {
    getList() {
      OAApi.getSynMarkerList(this.queryParams).then(res => {
        this.list = res.rows;
        this.total = res.total;
      })
    },
    cancel() {
      this.open = false;
      this.reset();
    },
    reset() {
      this.form = {};
      this.resetForm("form");
    },
    handleAdd() {
      this.$refs.editMark.add();
    },
    handleUpdate(row) {
      this.reset();
      this.open = true;
      this.title = "修改会议信息";
    },
    onSynMarkSave(data) {
      console.log(data);
      OAApi.saveSynMarker(data).then(res => {
        this.$modal.msgSuccess('协同标绘添加成功');
        this.getList();
      })
    },
    handleDelete(row) {
      this.$modal
        .confirm("是否确认删除该会议？")
        .then(function () { })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => { });
    },
    intoSynMark(data) {
      this.$tab.openPage("在线协同标绘", "/oa/mark/sysmarker", { plotId: data.plottingId });
    },
  },
};
</script>
